﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Photography.Admin
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack && !(Master as AdminMaster).AdminID.HasValue)
            {
                Photography.App_Data.PhotographyDataContext context = new Photography.App_Data.PhotographyDataContext();

                Photography.App_Data.GetAdminResult admin = context.GetAdmin(txtUsername.Text, txtPassword.Text).FirstOrDefault();

                if (admin != null)
                {
                    (Master as AdminMaster).AdminID = admin.ID;
                    (Master as AdminMaster).AdminName = admin.FullName;
                    (Master as AdminMaster).AdminEmail = admin.Email;
                }
            }
        }
    }
}